home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 1
/
LIGHT-ROM 1 (Amiga Library Services)(1994).iso
/
ffdisks
/
d963.lha
/
SIOD
/
scm
/
qsort.scm
< prev
next >
Wrap
Text File
|
1993-05-08
|
984b
|
26 lines
(define test >=)
(define (qsort! v m n)
(define (interchange i j)
(let ((t (vector-ref v i)))
(vector-set! v i (vector-ref v j))
(vector-set! v j t)))
(define (qsort-i m n)
(if (< m n)
(do ((i m)
(j (1+ n))
(k (vector-ref v m)))
((>= i j) (interchange m j)
(qsort-i m (-1+ j))
(qsort-i (1+ j) n))
(set! i (1+ i))
(do () ((or (test (vector-ref v i) k) (>= i n)))
(set! i (1+ i)))
(set! j (-1+ j))
(do () ((or (test k (vector-ref v j)) (<= j m)))
(set! j (-1+ j)))
(if (< i j)
(interchange i j)))))
(qsort-i m n))